/*************************************************
Author: byron
Date: 10/16/2012
Description:
Notes: 
*************************************************/

#ifndef __CPartnerCfg_h__
#define __CPartnerCfg_h__

#include "commclass.h"

enum ENUM_PARTNER_JOIN_WAY_TAG
{
    PARTNER_JOIN_WAY_DEFAULT = 0,//默认额外招募条件
    PARTNER_JOIN_WAY_FIRST_PAY = 1,//首充额外招募条件
    PARTNER_JOIN_WAY_RECEIVE_OR_FINISH_TASK = 2,//已接取或完成特定任务
    PARTNER_JOIN_WAY_RECEIVE_TASK = 3,//已接取特定任务
    PARTNER_JOIN_WAY_FINISH_TASK = 4,//完成特定任务
    PARTNER_JOIN_WAY_USE_ITEM = 5,//使用特定物品获得
    PARTNER_JOIN_WAY_BACKUP = 100,//备用额外招募条件
};

//伙伴配置项
class CPartnerMgr;
class CPartnerCfg;
class CPartnerUnit;
class CPartnerCfgData
{
    friend class CPartnerMgr;
    friend class CPartnerCfg;
    friend class CPartnerUnit;
public:

    CPartnerCfgData() 
    {
        Clear();
    }
    void Clear()
    {
        _bIsMan = false;
        _chCareer = 0;
        _shResID = 0;
        _iRepu = 0;
        _iSilver = 0;
        _iVit = 0;
        _iStr = 0;
        _iInt = 0;
        _iAgi = 0;
        _iSpeEffect = 0;
        _iStatusGroupID = 0;
        _iSignBattle = 0;
        _iSignSilver = 0;
        _iSignVit = 0;
        _iSignStr = 0;
        _iSignInt = 0;
        _iSignAgi = 0;
        _iLockBattle = 0;
        _iLockEffect = 0;
        _iWeaponID = 0;
        _iJoinWay = 0;
        _iJoinArgu = 0;
        _iJoinFrontID = 0;
        _uiNormalSkiID = 0;
        _uiMagicSkiID = 0;
        _stInitAttr.Clear();
    }

    virtual ~CPartnerCfgData() 
    {
    }

    bool IsValidID() const
    {
        return (_shResID > 0 && _shResID <= MAX_PARTNER_CFG_COUNT);
    }

    bool IsValidAttr()
    {
        return _stInitAttr.IsValidAttrValue();
    }

    bool IsValidJoinWay() const
    {
        return (PARTNER_JOIN_WAY_DEFAULT == _iJoinWay ||
            PARTNER_JOIN_WAY_FIRST_PAY == _iJoinWay ||
            IsAboutTaskJoinWay() ||
            PARTNER_JOIN_WAY_USE_ITEM == _iJoinWay ||
            PARTNER_JOIN_WAY_BACKUP == _iJoinWay);
    }

    bool IsAboutTaskJoinWay() const
    {
        return (PARTNER_JOIN_WAY_RECEIVE_OR_FINISH_TASK == _iJoinWay ||
            PARTNER_JOIN_WAY_RECEIVE_TASK == _iJoinWay ||
            PARTNER_JOIN_WAY_FINISH_TASK == _iJoinWay);
    }

    short GetResID() const {return _shResID;}
    char GetCareer() const {return _chCareer;}
    bool GetIsMan() const {return _bIsMan;}
    int GetStatusGroupID() const {return _iStatusGroupID;}
    int GetReq() const {return _iRepu;}

private:
    bool                _bIsMan;            //性别
    char                _chCareer;          //职业
    short               _shResID;           //资源ID
    int                 _iRepu;             //招募声望
    int                 _iSilver;           //招募银币

    //一级属性
    int                 _iVit;              //体力
    int                 _iStr;              //力量
    int                 _iInt;              //智力
    int                 _iAgi;              //敏捷
    int                 _iSpeEffect;        //特殊效果
    int                 _iStatusGroupID;    
    int                 _iSignBattle;       //契约需战斗次数
    int                 _iSignSilver;       //契约银币

    int                 _iSignVit;          //契约加体力
    int                 _iSignStr;          //契约加力量
    int                 _iSignInt;          //契约加智力
    int                 _iSignAgi;          //契约加敏捷

    int                 _iLockBattle;       //锁链需战斗次数
    int                 _iLockEffect;       //锁链效果
    int                 _iWeaponID;         //初始装备ID
    int                 _iJoinWay;          //额外招募条件
    int                 _iJoinArgu;         //额外招募参数
    int                 _iJoinFrontID;      //前端额外招募ID

    unsigned int        _uiNormalSkiID;      //普通技能ID
    unsigned int        _uiMagicSkiID;       //幻化技能ID

    CPlayerAttr         _stInitAttr;        //初始化二级属性
};

class CConditionData
{
public:

    CConditionData() 
    {
        Clear();
    }

    void Clear()
    {
        _iKey = 0;
        _iValue = 0;
        _iArgument = 0;
    }

    virtual ~CConditionData() 
    {
    }

public:
    int        _iKey;
    int        _iValue;
    int        _iArgument;
};

//伙伴配置
class CPartnerCfg
{
public:
    CPartnerCfg() 
    {
    }

    virtual ~CPartnerCfg() 
    {
    }

    int Init();

    int AddConfig(CPartnerCfgData& stCfgData);

    int FindConfig(short shResID);

    int GetPartnerCfgSize() const 
    {
        return _astPartnerCfgs.Size();
    }

    CPartnerCfgData& GetConfig(int iIndex) {return _astPartnerCfgs[iIndex];}

    int GetConditionSize() const {return _astCondition.Size();}
    CConditionData& GetCondition(int iIndex) {return _astCondition[iIndex];}
    void AddCondition(CConditionData& stConPair)
    {
        _astCondition.AddOneItem(stConPair);
    }

private:
    CTLib::CTArray<CConditionData, MAX_PARTNER_CFG_COUNT> _astCondition;
    CTLib::CTArray<CPartnerCfgData, MAX_PARTNER_CFG_COUNT> _astPartnerCfgs;
};

#endif // __CPartnerCfg_h__


